/**
 * Created by lanyanhua on 2018/10/31 0031.
 */
NProgress.start();
window.onload = function () {
    NProgress.done();
};
layui.use(['element', 'table', 'form', 'jquery', 'laydate', 'list'], function () {
    var table = layui.table;
    var form = layui.form;
    var $ = layui.jquery;
    var list = layui.list;

    var showdatatable = table.render({
        elem: '#tableId',
        id: "showdata",
        url: '/tuInfoLog/findTuInfoLogAll',
        limit: 10,
        page: true,
        while: param(),
        cols: [[
            {type: 'checkbox'},
            {field: 'roleName', title: '名称', width: 160},
            {field: 'device', title: '设备名称', width: 160},
            {field: 'remark', title: '信息备注', templet: '#roleTpl', width: 600},
            {
                field: 'createTime',
                title: '开始时间',
                width: 340,
                templet: '<div>{{ Format(d.createTime,"yyyy-MM-dd hh:mm:ss")}}</div>'
            }
        ]]

    });
    var listOpen = {
        elem: "#test6",
        readonly: "readonly",
        fields: {
            roleName: {label: "名称" }
            , device: {label: "设备名称"}
            , remark: {label: "信息备注"}
            , createTime: {label: "开始时间"}
        },
        btns: ["submit", 'reset'],
        area: ['80%', '90%']
    };
    form.on('submit(search)', function () {
        showdatatable.reload({where: param()});
        return false;
    });

    table.on('tool(tableFilter)', function (obj) {
        var data = obj.data;
        var layEvent = obj.event;
        if (layEvent === 'edit') {
            //console.log(data);updateJob
            data.success = data.success ? "成功" : "失败";
            data.startTime = Format(data.startTime, "yyyy-MM-dd hh:mm:ss");
            data.endTime = Format(data.endTime, "yyyy-MM-dd hh:mm:ss");
            listOpen.over = data;
            list.open(listOpen);
        }
    });

    function param() {
        return {
            roleName: $('[name=roleName]').val()
        }
    }
});
